We will be using regular experessions.

This is a good link, but uses Python 2: http://www.thegeekstuff.com/2014/07/python-regex-examples/


In [17]:
import requests
from bs4 import BeautifulSoup
import re

In [18]:
r = requests.get("http://pythonforengineers.com/dummy-sales-page/")
soup = BeautifulSoup(r.text, "lxml")

In [36]:
price_list = []
for elem in soup.find_all('p'):
    search = re.findall("Price for ([\w :]*) ([\w$]*)", elem.text)
    if search:
        #print(search)
        price_list.append(search)
print(price_list)
print(price_list[0])


[[('Item A:', '$99')], [('Item B:', '$29')], [('Item 3:', '$299')]]
[('Item A:', '$99')]